<?php

/*
 * ************************************************* 
 * Created on :2012-5-2 15:44:09
 * Encoding   :UTF-8
 * Description:
 * 
 * @Author @lqs <soso2501@gmail.com>
 * @WAP_WEIBO (C)1996-2099 SINA Inc. 
 * ************************************************
 */

class Copy {

    static $table = 'copy';

    public static function mod($title, $content, $remark) {
        if (empty($title))
            return false;
        $r = DB::GetTableRow(self::$table, array("copytitle" => $title));
        $data = array("copytitle" => $title, "content" => $content, "remark" => $remark);
        if (empty($r)) {
            return DB::Insert(self::$table, $data);
        } else {
            if ($r['content'] == $content && $r['remark'] == $remark)
                return true;
            else
                return DB::Update(self::$table, $title, $data, "copytitle");
        }
    }

    public static function get($title) {
        if (empty($title))
            return false;
        return DB::GetTableRow(self::$table, array("copytitle" => $title));
    }

    public static function alltitles() {
        $return = array();
        $r = DB::LimitQuery(self::$table, array("select" => "copytitle"));
        foreach ($r as $v)
            $return[] = $v['copytitle'];
        return $return;
    }

}

/* End of file Copy */


